<template>
  <ul class="songlist">
      <li v-for="value in list" :key='value.id' class="item" @click.stop="selectMusic(value.id)">
        <img v-lazy="value.picUrl" alt="">
        <div>
          <h3>{{value.name}}</h3>
          <p>{{value.singer}}</p>
        </div>
      </li>
    </ul>
</template>

<script>
import { mapActions } from 'vuex'
export default {
  name: 'SongList',
  data () { return {} },
  props: {
    list: {
      type: Array,
      default: () => [],
      required: true
    }
  },
  methods: {
    ...mapActions([
      'setFullPlayer',
      'setMiniPlayer',
      'getSongs'
    ]),
    selectMusic (id) {
      this.setFullPlayer(true)
      this.setMiniPlayer(false)
      this.getSongs(id)
    }
  }
}
</script>

<style scoped lang='scss'>
  @import "../assets/css/variable.scss";
  @import '../assets/css/mixin.scss';
  .songlist{
    .item{
      display: flex;
      align-items: center;
      padding: 20px 20px 0 20px;
      border-bottom: 1px solid #ccc;
      img{
        width: 150px;
        height: 150px;
        border-radius: 20px;
        margin-right: 20px;
      }
      div{
        width: 60%;
        h3{
          @include font_size($font_large);
          @include font_color();
          @include no-wrap();
        }
        p{
          @include font_size($font_medium_s);
          margin-top: 20px;
          @include no-wrap();
        }
      }
    }
  }
</style>
